﻿using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Zhaoxi.GrpcService
{
	public class RedisHelper
	{
		public static string url;
		static string setid = "servicelist";
		public static void Heartbeat()
		{
			using (RedisClient client = new RedisClient("127.0.0.1", 6379))
			{
				client.IncrementItemInSortedSet(setid, url,0);

				client.Set<string>(url, DateTime.Now.ToString("yyyyMMddHHmmssfff"), DateTime.Now.AddSeconds(6));//6秒钟消失
			}
		}
		
		public static void DeleteKey()
		{
			using (RedisClient client = new RedisClient("127.0.0.1", 6379))
			{
				//删除string里面的key
				client.Del(url);
				client.RemoveItemFromSortedSet(setid, url);
			}
		}
	}
}
